import os.path

from tools.ExcelHandler import ExcelHandler
from functions.FinalWrite import FinalWrite
from collect.AcquireSN import AcquireSN

if __name__ == '__main__':
    # 基础信息,服务器ip,用户,password,要写入的excel文件,
    url = "http://10.231.43.135"
    username = "admin"
    password = "Pa55w0rd!!"
    excel_file = 'test.xlsx'
    sn_json_file = 'sn.json'
    hosts = url.split('.')[-1]
    # 创建对象，获取sn号
    SN = AcquireSN(url, username, password, sn_json_file)
    SN.get_sn()
    # 创建对象，写入excel
    if os.path.exists(sn_json_file):
        handler = ExcelHandler(excel_file, hosts)
        final_write = FinalWrite(sn_json_file, handler)
        final_write.run()
    else:
        print("写入失败")
